package com.tom;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;





import com.mysql.jdbc.Driver;

public class DBTester {

	public static void main(String[] args) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		try {
			DriverManager.registerDriver(new Driver());
			conn = DriverManager.getConnection("jdbc:mysql://j.snpy.org/j102", "jstu", "abc123");
			String sq1 = "select * from users";
			pstmt = conn.prepareStatement(sq1);
			ResultSet rs = pstmt.executeQuery();
			while (rs.next()){
			String userid = rs.getString("id");
			String nickname = rs.getString("nickname");
			String password = rs.getString("password");
			String email = rs.getString("email");
			System.out.println(userid + "/" + nickname + "/" + password + "/" + email);
			}	
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			try {
				if (conn !=null && pstmt !=null)
				pstmt.close();
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
